<template>
	<tn-popup v-model="isShow" mode="bottom" :maskCloseable="false" :safeAreaInsetBottom="true" @close="close">
		<view class="filter-container">
			<view class="safe-box-style" :style="safeBoxStyle">
				<view class="use-close-btn-wrap" @click.stop="isShow = false">取消</view>
			</view>
			<view class="popup-container">
				<template v-if="perName == 'album'">
					<view class="t-wrap">
						<view class="t1">无法访问相册中照片</view>
						<view class="t2">
							<view>当前无照片访问权限，建议前往系统设置，允许</view>
							<view>海豚圈圈访问「相册」中的「所有照片」。</view>
						</view>
					</view>
				</template>
				<template v-if="perName == 'camera'">
					<view class="t-wrap">
						<view class="t1">无法访问相机</view>
						<view class="t2">
							<view>当前无相机访问权限，无法录制视频/拍照，</view>
							<view>建议前往系统设置，允许海豚圈圈访问「相机」。</view>
						</view>
					</view>
				</template>
				<template v-if="perName == 'microphone'">
					<view class="t-wrap">
						<view class="t1">无法访问麦克风</view>
						<view class="t2">
							<view>当前无麦克风访问权限，</view>
							<view>无法发布动态、圈子、视频录制和语音录制，</view>
							<view>建议前往系统设置，允许海豚圈圈访问「麦克风」。</view>
						</view>
					</view>
				</template>

			</view>
			<view class="bottom-operation">
				<view class="btn btn2" @click.stop="gotoSetting">前往系统设置</view>
			</view>
		</view>
	</tn-popup>
</template>

<script>
	import {
		gotoAppPermissionSetting
	} from "@/tools/permision.js"
	export default {
		data() {
			return {
				isShow: false,
				// 权限名称，album-相册；camera-相机；microphone-麦克风
				perName: "album",

				safeBoxStyle: {
					height: 0
				}
			};
		},
		mounted() {
			// const sys = uni.getSystemInfoSync()
			// this.safeBoxStyle.height = sys.statusBarHeight + 'px';
		},
		methods: {
			gotoSetting() {
				gotoAppPermissionSetting();
				this.close();
			},
			async open(vals) {
				const {
					perName
				} = vals
				this.perName = perName;
				uni.hideTabBar()
				this.isShow = true
			},
			close() {
				uni.showTabBar()
				this.isShow = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.filter-container {
		display: flex;
		flex-direction: column;
		height: 100vh;
		padding: 0 32rpx;

		.safe-box-style {
			position: relative;

			.use-close-btn-wrap {
				position: absolute;
				right: 0;
				bottom: -60rpx;
				padding: 10rpx 20rpx;
			}
		}

		.popup-container {
			flex: 1;
			display: flex;
			align-items: center;
			justify-content: center;

			.t-wrap {
				text-align: center;
				position: relative;
				top: -120rpx;
			}

			.t1 {
				font-size: 40rpx;
				font-weight: 600;
				color: #303030;
			}

			.t2 {
				font-size: 26rpx;
				line-height: 38rpx;
				color: #303030;
				margin-top: 60rpx;
			}
		}

		.bottom-operation {
			height: 260rpx;
			display: flex;
			justify-content: center;

			.btn {
				width: 300rpx;
				height: 76rpx;
				line-height: 76rpx;
				text-align: center;
				font-size: 28rpx;
				font-weight: 500;
				border-radius: 38rpx;
			}

			.btn2 {
				color: #ffffff;
				background-color: #FE5680;
			}
		}
	}
</style>